const { table } = require("table");

const siya = parseInt(process.argv[2]) || 800;

const data = [
  ["siya", siya],
  ["siya ^ 2", format((siya * (siya + 1) * 17) / 2)]
];
data.push(["argaiv", siya]);
data.push(["atman(687)", format(2.832 * Math.log(siya) - 7.02)]);
data.push(["bhaal", format(siya * 0.8)]);
data.push(["bubos(426)", format(2.832 * Math.log(siya) - 5.94)]);
data.push(["chronos(236)", format(2.75 * Math.log(siya) - 6.05)]);
data.push(["dogcog(920)", format(2.877 * Math.log(siya) - 7)]);
data.push(["dora", format(2.877 * Math.log(siya) - 9.63)]);
data.push(["fortuna(3684)", format(2.875 * Math.log(siya) - 9.3)]);
data.push(["fragsworth", format(siya)]);
data.push(["juggernaut", format(siya * 0.1)]);
data.push(["kuma(669)", format(2.844 * Math.log(siya) - 5.043)]);
data.push(["mammon", format(siya * 0.9)]);
data.push(["mimzee", format(siya * 0.9)]);
data.push(["morgulis", format(Math.pow(siya, 2))]);
data.push(["revolc(921)", format(Math.log2(siya * siya + siya + 6) - 2)]);
data.push(["vaagur(244)", ""]);
data.push(["pluto", format(siya * 0.5)]);

console.log(table(data));

function format(n) {
  const UNITS = ["", "k", "M", "B", "T"];
  if (n < 100) {
    return n.toFixed(2);
  }

  const exponent = Math.min(
    Math.floor(Math.log10(n) / 3),
    UNITS.length - 1
  );
  const number = Number((n / Math.pow(1000, exponent)).toPrecision(3));

  return number + UNITS[exponent];
}
